<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" isELIgnored="false"%>
<%@ include file="/common/common.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>${siteName}</title>
        <%@ include file="/common/commonstyle.jsp" %>
        <script type="text/javascript"> 
            $("#email").val("111");
            $(function() {
                    $("#registerForm").submit(function(){
                            var email = $("#email").val();
                            var password = $("#password").val();
                            if(null == email || "" == email) {
                                    jAlert("<spring:message code='loginempty' />");
                                    return false;
                            } else if(null == password || "" == password) {
                                    jAlert("<spring:message code='loginempty' />");
                                    return false;
                            } else {
                                    return true;
                            }
                    });
                    $("#loginForm").submit(function(){
                            var email = $("#loginEmail").val();
                            var password = $("#loginPassword").val();
                            if(null == email || "" == email) {
                                    jAlert("<spring:message code='loginempty' />");
                                    return false;
                            } else if(null == password || "" == password) {
                                    jAlert("<spring:message code='loginempty' />");
                                    return false;
                            } else {
                                    return true;
                            }
                    });
                    //验证信息
                    $.formValidator.initConfig({
                            formID: "registerForm",
                            debug:false,
                            onError: function(msg, obj, errorlist){
                                    jAlert(msg);
                            }
                    });

                    $("#email").formValidator({onShow:"请输入email", onCorrect:"恭喜你,你输对了"}).regexValidator({regExp: "email", dataType:"enum", onError:"你输入的email格式不正确"})
                .ajaxValidator({
                            dataType : "json",
                            async : true,
                            url : "${base}/frontUserCtl/checkEmailName",
                            success : function(data){
                                    if(data == "0" ) {
                            return true;
                            } else {
                                            return "该email已被使用，请更换";
                                    }
                            },
                            buttons: $("#submitBtn"),
                            error: function(jqXHR, textStatus, errorThrown) {
                                    alert("服务器没有返回数据，可能服务器忙，请重试" + errorThrown);
                            },
                            onError : "该email已被使用，请更换email",
                            onWait : "正在对email进行合法性校验，请稍候..."
                    });
                    $("#password").formValidator({onShow:"请输入密码",onFocus:"至少6个长度",onCorrect:"密码合法"}).inputValidator({min:6, max:25, empty:{leftEmpty:false,rightEmpty:false,emptyError:"密码两边不能有空符号"},onError:"密码为6-25个字符,请确认"}).regexValidator({regExp: "Illegal", dataType:"enum", onError:"密码中包含非法字符"});
                    $("#repassword").formValidator({onShow:"输再次输入密码",onFocus:"至少6个长度",onCorrect:"密码一致"}).inputValidator({min:6, max:25, empty:{leftEmpty:false,rightEmpty:false,emptyError:"重复密码两边不能有空符号"},onError:"重复密码为6-25个字符,请确认"}).compareValidator({desID:"password",operateor:"=",onError:"两次密码不一致,请确认"});
                    $("#randomCode").formValidator({onShow:"请输入验证码", onCorrect:"恭喜你,你输对了"}).inputValidator({min:4, max:4, onError:"验证码输入错误"})
                    .ajaxValidator({
                            dataType : "json",
                            async : true,
                            url : "${base}/frontUserCtl/checkRandomCode",
                            success : function(data){
                                    if(data == "1" ) {
                            return true;
                            } else {
                                            return "验证码输入错误";
                                    }
                            },
                            buttons: $("#submitBtn"),
                            error: function(jqXHR, textStatus, errorThrown) {
                                    alert("服务器没有返回数据，可能服务器忙，请重试" + errorThrown);
                            },
                            onError : "验证码输入错误错误",
                            onWait : "正在校验验证码，请稍候..."
                    });
            });
    </script>
        <script type="text/javascript">
            $(function() {
                document.forms[0].target = "_self";
                document.forms[1].target = "_self";
            });
            <c:if test="${message != null && message != ''}">
                alert('${message}')
            </c:if>
        </script>
    </head>
    <body>
        <table cellpadding="0" cellspacing="0" border="0">
            <tr>
                <td width="50%" valign="top">
                    <form:form id="registerForm" commandName="user" method="post" action="${base}/frontUserCtl/register" target="_top">
                        <div class="login_zc">
                            <h2><spring:message code="register" /></h2>
                            <ul>
                                <li>
                                        <span>*E-mail：</span>
                                        <input type="text" id="email" name="email" class="text_zc" />
                                </li>
                                <li>
                                        <span>*<spring:message code="password" />：</span>
                                        <input type="password" id="password" name="password" class="text_zc" maxlength="25" />
                                </li>
                                <li>
                                    <span>*<spring:message code="repassword" />：</span>
                                    <input type="password" id="repassword" class="text_zc" maxlength="25" />
                                </li>
                                <li>
                                        <span><spring:message code="securitycode" />：</span>
                                        <input type="text" id="randomCode" name="randomCode" class="text_zc" maxlength="4" style="width: 130px" />
                                                    <img id="randomCodeImg" style="cursor:pointer;" title="点击更换" onclick="this.src='${base}/securityCode/loadSecurityCode?' + Math.random()" src="${base}/securityCode/loadSecurityCode" />
                                </li>
                                <li>
                                        <input type="hidden" id="submitMark" name="submitMark" value="${registerSubmitMark }"/>
                                    <input id="submitBtn" type="submit" value="<spring:message code="registernow" />" class="btn_zc01" />
                                </li>
                            </ul>
                        </div>
                    </form:form>
                </td>
                <td valign="top">
                    <form:form id="loginForm" method="post" action="${base}/frontUserCtl/userLogin" target="_top">
                        <div class="login_dl">
                            <h2><spring:message code="login" /></h2>
                                <ul>
                                        <li>
                                            <span>E-mail：</span>
                                            <input type="text" id="loginEmail" name="email" class="text_dl" />
                                        </li>
                                        <li>
                                            <span><spring:message code="password" />：</span>
                                            <input type="password" id="loginPassword" name="password" class="text_dl" />
                                        </li>
                                        <li style="text-align:center;padding-left: 35%">
                                            <input type="submit" value="<spring:message code='login' />" class="btn_dl" />
                                        </li>
                                </ul>
                        </div>
                    </form:form>
                </td>
            </tr>
        </table>
        <br/>
</body>
</html>